/*   1:    */ package com.intellij.licensecommon.util;
/*   2:    */ 
/*   3:    */

import com.intellij.licensecommon.message.Message;

import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

/*   4:    */
/*   5:    */
/*   6:    */
/*   7:    */
/*   8:    */
/*   9:    */

/*  10:    */
/*  11:    */ public class MessageCache
/*  12:    */ {
/*  13:    */   private Policy a;
/*  14: 14 */   private final Map b = new HashMap();
/*  15:    */   
/*  16:    */   public MessageCache()
/*  17:    */   {
/*  18: 17 */     this(new a_());
/*  19:    */   }
/*  20:    */   
/*  21:    */   public MessageCache(Policy paramPolicy)
/*  22:    */   {
/*  23: 21 */     this.a = paramPolicy;
/*  24:    */   }
/*  25:    */   
/*  26:    */   public synchronized boolean a(String paramString)
/*  27:    */   {
/*  28: 25 */     return this.b.containsKey(paramString);
/*  29:    */   }
/*  30:    */   
/*  31:    */   public synchronized void a(String paramString, Message paramMessage)
/*  32:    */   {
/*  33: 29 */     Date localDate = this.a.a();
/*  34: 30 */     b_ localb_ = new b_(paramMessage, localDate);
/*  35: 31 */     this.b.put(paramString, localb_);
/*  36:    */   }
/*  37:    */   
/*  38:    */   public synchronized Message b(String paramString)
/*  39:    */   {
/*  40: 35 */     b_ localb_ = c(paramString);
/*  41: 36 */     if (localb_ == null) {
/*  42: 36 */       return null;
/*  43:    */     }
/*  44: 37 */     localb_.a(this.a.a());
/*  45: 38 */     return localb_.a();
/*  46:    */   }
/*  47:    */   
/*  48:    */   private b_ c(String paramString)
/*  49:    */   {
/*  50: 42 */     return (b_)this.b.get(paramString);
/*  51:    */   }
/*  52:    */   
/*  53:    */   Date d(String paramString)
/*  54:    */   {
/*  55: 46 */     b_ localb_ = c(paramString);
/*  56: 47 */     if (localb_ == null) {
/*  57: 47 */       return null;
/*  58:    */     }
/*  59: 48 */     return localb_.b();
/*  60:    */   }
/*  61:    */   
/*  62:    */   public synchronized void a(long paramLong)
/*  63:    */   {
/*  64: 52 */     Date localDate = new Date(this.a.a().getTime() - paramLong);
/*  65: 53 */     for (Iterator localIterator = this.b.entrySet().iterator(); localIterator.hasNext();)
/*  66:    */     {
/*  67: 54 */       Map.Entry localEntry = (Map.Entry)localIterator.next();
/*  68: 55 */       b_ localb_ = (b_)localEntry.getValue();
/*  69: 56 */       if (a(localb_, localDate)) {
/*  70: 57 */         localIterator.remove();
/*  71:    */       }
/*  72:    */     }
/*  73:    */   }
/*  74:    */   
/*  75:    */   private boolean a(b_ paramb_, Date paramDate)
/*  76:    */   {
/*  77: 64 */     if (paramb_ == null) {
/*  78: 64 */       return true;
/*  79:    */     }
/*  80: 65 */     return a(paramb_.b(), paramDate);
/*  81:    */   }
/*  82:    */   
/*  83:    */   private boolean a(Date paramDate1, Date paramDate2)
/*  84:    */   {
/*  85: 69 */     if (paramDate1 == null) {
/*  86: 69 */       return true;
/*  87:    */     }
/*  88: 70 */     return paramDate1.compareTo(paramDate2) < 0;
/*  89:    */   }
/*  90:    */   
/*  91:    */   private static class b_
/*  92:    */   {
/*  93:    */     private final Message a;
/*  94:    */     private Date b;
/*  95:    */     
/*  96:    */     public b_(Message paramMessage, Date paramDate)
/*  97:    */     {
/*  98: 78 */       this.a = paramMessage;
/*  99: 79 */       this.b = paramDate;
/* 100:    */     }
/* 101:    */     
/* 102:    */     public Message a()
/* 103:    */     {
/* 104: 83 */       return this.a;
/* 105:    */     }
/* 106:    */     
/* 107:    */     public Date b()
/* 108:    */     {
/* 109: 87 */       return this.b;
/* 110:    */     }
/* 111:    */     
/* 112:    */     public void a(Date paramDate)
/* 113:    */     {
/* 114: 91 */       this.b = paramDate;
/* 115:    */     }
/* 116:    */   }
/* 117:    */   
/* 118:    */   public static abstract interface Policy
/* 119:    */   {
/* 120:    */     public abstract Date a();
/* 121:    */   }
/* 122:    */   
/* 123:    */   public static class a_
/* 124:    */     implements MessageCache.Policy
/* 125:    */   {
/* 126:    */     public Date a()
/* 127:    */     {
/* 128:102 */       return new Date();
/* 129:    */     }
/* 130:    */   }
/* 131:    */ }



/* Location:           E:\idea\

 * Qualified Name:     com.intellij.a.g.MessageCache

 * JD-Core Version:    0.7.0.1

 */